import _thread
import asyncio
import sys
import threading
import time

from util.DataQuery.DbTools import DbTools
from util.g import g


class Write():


    a = False
    b = False

    # a = 'aaaaaaaaaaaaaaaaaaaaaaaaa'
    #
    # b = 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'

    co_id = 10

    def p(self):

        print(self.a)

    def app(self):

        wa = write_app()
        wa.o()

class write_app():

    def __init__(self):
        sql = f"""
            select ('cert_org', 'app_date') from ent_yearstatus where co_id={co_id};
        """

    def o(self):
        print(self.sql)

class check():

    def __init__(self, num):

        self.num = num

    def main(self):
        if self.num == 10:

            sys.exit()


class test():
    ab = 'start'.center(105, '=')

    def __init__(self):
        ab = 'start'.center(105, '=')

    @classmethod
    def main(cls):
        print(cls.ab)



# class a():
#
#     def main(self):
#         print(self.__class__.__name__)
#
# class b(a):
#
#     def main(self):
#         print(self.__class__.__name__)
#         print(self.__class__.__bases__)



class ab():


    @property
    def handel_date(self, date):

        return date

    def main(self, a=1, b=2):
        print(self.handel_date(date='2019'))

def func(fun, *args, **kwargs):
    print(fun.__code__.co_varnames, 'in func')
    for i in dir(fun.__code__):
        print(f'{i} ------- {getattr(fun.__code__, i)}')


#  图片下载的地址：  http://www.wo-ict.com/enterprise-genealogy/graph/draw/downImage.do


def out(func):
    def wrapper(*args, **kwargs):
        arg_list = [args[0], "wangyt"]
        print(args)
        func(*arg_list)
    return wrapper

class TEST():

    def __call__(self, *args, **kwargs):
        print("fjsdoifjdifjdsio")

    @out
    def main(self, last=""):
        print("this is test class" + " {}".format(last))

async def a():
    while True:
        if Write.a is True:
            print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
        # else:
        #     await asyncio.sleep(0.1)

def b():
    while True:
        if Write.b is True:
            print("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
            break

def func():
    while True:
        yield False
        try:
            if Write.a is True:
                print("completed")
        except Exception as err:
            pass

if __name__ == '__main__':

    # a = "1"
    # li = []
    # def change(li):
    #     li.append(1)
    # print(li)
    # change(li)
    # print(li)

    

    # print(a)
    # change(a)
    # print(a)
    # g.co_id = 882017
    # g.year = 2021
    # file_stat = "320000:0,taxAudit:0,disable:1,ctp:0"
    # file_stat = "320000:1,taxAudit:0,disable:0,ctp:1"
    # file_stat = "320000:1,taxAudit:0,disable:0,ctp:1"
    # li = {i.split(":")[0]: i.split(":")[1] for i in file_stat.split(",")}
    # need_file = True
    # if li.get("disable") == '1':
    #     need_file = False
    # else:
    #     if li.get("ctp") == '0':
    #         need_file = False
    # print("是否需要附件: ", need_file)
    # if g.need_file is True:
    #     is_split = DbTools.get_ent_files_completed(co_id=g.co_id, year=g.year)
    #     if is_split is False:
    #         print("等待附件拆分: {}-{}".format(g.co_id, g.entname))



    # i = ab()
    # func(i.main)
    # globals().get("TEST")().main()
    # var = "abc"
    # a = [1, 2, 3, 4, 5, 6]
    # setattr(Write, var, list())
    # var_ = getattr(Write, var)
    # for i in a:
    #     var_.append(i)
    # print(Write.abc)




    pass

